﻿namespace UFIDA.U9.Cust.SH.SHFastShipBP
{
	using System;
	using System.Collections.Generic;
	using System.Text; 
	using UFSoft.UBF.AopFrame;	
	using UFSoft.UBF.Util.Context;
    using UFIDA.U9.SM.Ship;
    using UFIDA.U9.Base;

	/// <summary>
	/// GetDefaultDocType partial 
	/// </summary>	
	public partial class GetDefaultDocType 
	{	
		internal BaseStrategy Select()
		{
			return new GetDefaultDocTypeImpementStrategy();	
		}		
	}
	
	#region  implement strategy	
	/// <summary>
	/// Impement Implement
	/// 
	/// </summary>	
	internal partial class GetDefaultDocTypeImpementStrategy : BaseStrategy
	{
		public GetDefaultDocTypeImpementStrategy() { }

		public override object Do(object obj)
		{						
			GetDefaultDocType bpObj = (GetDefaultDocType)obj;
			
			//get business operation context is as follows
			//IContext context = ContextManager.Context	
			
			//auto generating code end,underside is user custom code
			//and if you Implement replace this Exception Code...
			//throw new NotImplementedException();

            //Effective.IsEffective=1 and Effective.EffectiveDate<='#Context.DateTime#' and Effective.DisableDate>='#Context.DateTime#' and Org=#Context.OrgID#

            string opath = "";
            opath += " Effective.IsEffective=1";
            opath += " and Effective.EffectiveDate<='"+Context.LoginDateTime+"'";
            opath += " and Effective.DisableDate>='" + Context.LoginDateTime + "'";
            opath += " and Org="+Context.LoginOrg.ID;
            opath += " order by Code";

            ShipDocType doctype = ShipDocType.Finder.Find(opath);
            if (doctype == null) throw new Exception("查找不到单据类型！");

            EntityDTO dto = new EntityDTO();
            dto.ID = doctype.ID;
            dto.Code = doctype.Code;
            dto.Name = doctype.Name;

            return dto;
		}		
	}

	#endregion
	
	
}